package com.cdtu.store.api;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cdtu.store.common.entity.SkuEntity;
import com.cdtu.store.common.entity.SpuDetailEntity;
import com.cdtu.store.common.entity.SpuEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

@RequestMapping("goods")
public interface GoodsApi {
    /**
     * 分页查询商品
     * @param params
     * @param saleable
     * @return
     */
    @GetMapping("/spu/page")
    Page<SpuEntity> querySpuByPage(@RequestParam Map<String, Object> params, @RequestParam(value = "saleable", defaultValue = "true") Integer saleable);

    /**
     * 根据spu商品id查询详情
     * @param id
     * @return
     */
    @GetMapping("/spu/detail/{id}")
    SpuDetailEntity querySpuDetailById(@PathVariable("id") Long id);

    /**
     * 根据spu的id查询sku
     * @param id
     * @return
     */
    @GetMapping("sku/list")
    List<SkuEntity> querySkusBySpuId(@RequestParam("id") Long id);

    /**
     * 根据spu的id查询spu
     * @param id
     * @return
     */
    @GetMapping("spu/{id}")
    SpuEntity querySpuById(@PathVariable("id") Long id);

    @GetMapping("sku/{id}")
    public SkuEntity querySkuById(@PathVariable("id")Long id);
}
